//
//  HWGameCommunityPlayVideo.swift
//  HWanGame
//
//  Created by 王昌健 on 2022/10/26.
//  Copyright © 2022 94Wan. All rights reserved.
//

import UIKit
import ZLPhotoBrowser
class HWGameCommunityPlayVideo: NSObject {
    @objc class func playVideo(controller:UIViewController,model:HWGameCommunityDetailModel) -> Void {
        let vc = ZLImagePreviewController(datas: [URL(string: model.video)!], index: 0, showSelectBtn: false,showBottomView: false) { (url) -> ZLURLType in
            
            return .video
        } urlImageLoader: { (url, imageView, progress, loadFinish) in
            imageView.kf.setImage(with: url) { (receivedSize, totalSize) in
                let percentage = (CGFloat(receivedSize) / CGFloat(totalSize))
                debugPrint("\(percentage)")
                progress(percentage)
            } completionHandler: { (_) in
                loadFinish()
            }
        }
        
        vc.doneBlock = { (datas) in
            debugPrint(datas)
        }
        
        vc.modalPresentationStyle = .fullScreen
        controller.showDetailViewController(vc, sender: nil)
    }
    
    @objc class func clickImage(controller:UIViewController,model:HWGameCommunityDetailModel,index:Int) -> Void {
        var datas: [Any] = []
        for a in model.image {
            if a.count > 0 {
                datas.append(URL(string: a)!)
            }
        }
        let vc = ZLImagePreviewController(datas: datas, index: index, showSelectBtn: false,showBottomView: false) { (url) -> ZLURLType in
            
            return .image
        } urlImageLoader: { (url, imageView, progress, loadFinish) in
            imageView.kf.setImage(with: url) { (receivedSize, totalSize) in
                let percentage = (CGFloat(receivedSize) / CGFloat(totalSize))
                debugPrint("\(percentage)")
                progress(percentage)
            } completionHandler: { (_) in
                loadFinish()
            }
        }
        
        vc.doneBlock = { (datas) in
            debugPrint(datas)
        }
        
        vc.modalPresentationStyle = .fullScreen
        controller.showDetailViewController(vc, sender: nil)
    }
}
